using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.AccountsDomain;
using ShivamEMR.Model.DataInterfaces.AccountsDataInterf;
using ShivamEMR.Model;


namespace ShivamEMR.Web.Areas.Accounts.Controllers
{   
    public class AccountNatureController : Controller
    {
		private readonly IAccountNatureRepository accountnatureRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public AccountNatureController()// : this(new AccountNatureRepository())
        {
            this.accountnatureRepository = Registry.RepositoryFactory.GetAccountNatureRepository();
        }

        public AccountNatureController(IAccountNatureRepository accountnatureRepository)
        {
			this.accountnatureRepository = accountnatureRepository;
        }

        //
        // GET: /AccountNature/

        public ViewResult Index()
        {
            return View(accountnatureRepository.All);//Including(accountnature => accountnature.Rules, accountnature => accountnature.AccountsPostingTypes, accountnature => accountnature.Accounts));
        }

        //
        // GET: /AccountNature/Details/5

        public ViewResult Details(int id)
        {
            return View(accountnatureRepository.Find(id));
        }

        //
        // GET: /AccountNature/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /AccountNature/Create

        [HttpPost]
        public ActionResult Create(AccountNature accountnature)
        {
            if (ModelState.IsValid) {
                accountnatureRepository.InsertOrUpdate(accountnature);
                accountnatureRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /AccountNature/Edit/5
 
        public ActionResult Edit(int id)
        {
             return View(accountnatureRepository.Find(id));
        }

        //
        // POST: /AccountNature/Edit/5

        [HttpPost]
        public ActionResult Edit(AccountNature accountnature)
        {
            if (ModelState.IsValid) {
                accountnatureRepository.InsertOrUpdate(accountnature);
                accountnatureRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /AccountNature/Delete/5
 
        public ActionResult Delete(int id)
        {
            return View(accountnatureRepository.Find(id));
        }

        //
        // POST: /AccountNature/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            var a = accountnatureRepository.Find(id);
            accountnatureRepository.Delete(a);
            accountnatureRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

